package com.zisu.aradvertising.controller;


import com.zisu.aradvertising.pojo.Cooperation;
import com.zisu.aradvertising.pojo.Result;
import com.zisu.aradvertising.pojo.business.Cooperation1;
import com.zisu.aradvertising.service.Cooperation1Service;
import com.zisu.aradvertising.service.CooperationService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/cooperation1")
public class Cooperation1Controller {
    @Resource
    private Cooperation1Service cooperation1Service;
    //返回广告商所有的交易中心合作信息
    @PostMapping("/findallbypidjiaoyizhongxin")
    public Result<List<Cooperation1>> findAllbypidController(@RequestParam int pid){
        List<Cooperation1> cooperation3=cooperation1Service.findallbypidService(pid);
        if (cooperation3.size()!=0) {
            return Result.success(cooperation3, "返回交易中心合作信息成功!");
        } else{
            return  Result.error("123","交易中心无历史订单");
        }
    }

    //返回广告商所有待处理交易的的合作信息
    @PostMapping("/findallbypidjiaoyijilu")
    public Result<List<Cooperation1>> findAllbypidjiaoyijiluController(@RequestParam int pid){
        List<Cooperation1> cooperation3=cooperation1Service.findallbypidjiaoyijiluService(pid);
        if (cooperation3.size()!=0) {
            return Result.success(cooperation3, "返回交易记录合作信息成功!");
        } else{
            return  Result.error("123","交易记录无历史订单");
        }
    }
    //返回UP主一个广告位下的待处理交易
    @PostMapping("/findallbyapidgoing")
    public Result<List<Cooperation1>> findAllbyapidgoingController(@RequestParam int apid){
        List<Cooperation1> cooperation4=cooperation1Service.findallbyapidgoingService(apid);
        if (cooperation4.size()!=0) {
            return Result.success(cooperation4, "!");
        } else{
            return  Result.error("123","交易记录无历史订单");
        }
    }
    //返回up主一个广告位下的已成交记录
    @PostMapping("/findallbyapidover")
    public Result<List<Cooperation1>> findAllbyapidoverController(@RequestParam int apid){
        List<Cooperation1> cooperation5=cooperation1Service.findallbyapidoverService(apid);
        if (cooperation5!=null) {
            return Result.success(cooperation5, "返回已成交记录!");
        } else{
            return  Result.error("123","无成交记录");
        }
    }

}
